package org.example.lottery_system.common.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.example.lottery_system.common.errorcode.ErrorCode;
import org.example.lottery_system.common.errorcode.ServiceErrorCodeConstants;

//Data生成自己的hasxcode和equals不写Eq..这个可能会出问题
@Data
@EqualsAndHashCode(callSuper = true)
public class ServiceException extends RuntimeException {
    /**
     * @see org.example.lottery_system.common.errorcode.ServiceErrorCodeConstants
     */
    private Integer code;
    private String message;

    public ServiceException() {

    }

    public ServiceException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ServiceException(ErrorCode errorCode) {

        this.code = errorCode.getCode();
        this.message = errorCode.getMsg();
        System.out.println(new RuntimeException().getMessage());
    }
}
    //public UserNameException(String message){
//    this.message = message;
//}
//    public static void main(String[] args) {
//        try {
//            throw new ServiceException(ServiceErrorCodeConstants.PASSORD_ERROR);
//        }catch (Exception e){
//            System.out.println("测试getMessage->"+e.getMessage());
//        }
//    }
//}
